program IocpCxtServer;

uses
  //FastMM4,
  SysUtils,
  Windows,
  uDZProcess,
  Consts in '..\common\Consts.pas',
  uCLDWProtocol in '..\common\uCLDWProtocol.pas',
  uCxtConst in '..\common\uCxtConst.pas',
  uCxtPackage in '..\common\uCxtPackage.pas',
  uCxtTypes in '..\common\uCxtTypes.pas',
  uGoogleMap in '..\common\uGoogleMap.pas',
  uLBMPTrackClient in '..\common\uLBMPTrackClient.pas',
  uTcpDef in '..\common\uTcpDef.pas',
  uViDef in '..\common\uViDef.pas',
  uADODatabase in 'uADODatabase.pas',
  uAppCmdLineParams in 'uAppCmdLineParams.pas',
  uAppConfig in 'uAppConfig.pas',
  uAppLog in 'uAppLog.pas',
  uCxtDAL in 'uCxtDAL.pas',
  uCxtDALVDCenter in 'uCxtDALVDCenter.pas',
  uCxtNet in 'uCxtNet.pas',
  uCxtServer in 'uCxtServer.pas',
  uCxtSession in 'uCxtSession.pas',
  uDBConnPool in 'uDBConnPool.pas',
  uLBMPPackage in '..\common\uLBMPPackage.pas',
  uService in 'uService.pas',
  uLbmpNet in 'uLbmpNet.pas',
  uAsync in 'uAsync.pas',
  uSocket in 'uSocket.pas';

{$R *.res}

var
  Service: TService;

function ConsoleCtrlHandler(Ctrl: DWORD): BOOL; stdcall;
begin
  Service.Stop;
  Result := True;
end;

begin
  ReportMemoryLeaksOnShutdown := CmdLineParams.DebugMode;
  if CmdLineParams.RunMode = pemNormal then
  begin
    AllocConsole;
    SetConsoleCtrlHandler(@ConsoleCtrlHandler, True);
  end;
  Service.Initialize;
  try
    if CmdLineParams.RunMode = pemNormal then Service.Execute
    else Service.Run;
  finally
    Service.Finalize;
  end;
end.
